const catModel = require('../../db/cat')
const respJson = require('../../utils/respJson')
const writeErr = require('../../utils/writeErr')

module.exports = {
    //处理获取所有分类
    async getall(req, resp) {
        //获取数据库中的所有数据
        try {
            let docs = await catModel.find()
            respJson(resp, 200, '分类获取成功！', {
                cats: docs
            })
        } catch (err) {
            writeErr(err)
            //查询失败
            respJson(resp, 504, '分类获取失败！')
        }
    }
}